
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_app/mylib/SecondPage.dart';
import 'MineQRCode.dart';
import 'PersonalMes.dart';

class Mine extends StatefulWidget {
  Todo todo;
  Mine({Key key,@ required this.todo}) : super(key: key);
  State<StatefulWidget> createState() {
    return  MineState(todo: this.todo);
  }

}

@override


void main() => runApp(new MaterialApp(home: Mine()));

class MineState extends State<Mine> {

  String username = '小明';
  Todo todo;
  MineState({Key key, this.todo});
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        routes: {
          'MineQRCode':(BuildContext context)=>MineQRCode()
        },
        home: Scaffold(
      appBar: AppBar(
          backgroundColor: Color.fromRGBO(51, 51, 51, 1),
          titleSpacing: 0.0,
          title: Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              FlatButton(
                materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
                child: Row(
                  children: [
                    Icon(
                      Icons.arrow_back_ios,
                      color: Colors.white,
                    ),
                    Text(
                      '返回',
                      style: TextStyle(color: Colors.white, fontSize: 16),
                    )
                  ],
                ),
                onPressed: () {
                  Navigator.pop(context);
                },
              ),
              Container(
                child: Row(
                  children: [
                    Text(
                      '我的',
                      style: TextStyle(fontSize: 16),
                    ),
                    SizedBox(
                      width: 25,
                    )
                  ],
                ),
              ),
              IconButton(icon: Icon(Icons.more_horiz), onPressed: () {})
            ],
          )),
      body: Column(
        children: <Widget>[

          Center(
            child: GestureDetector(
              child: Container(
                width: 100,
                height: 100,
                margin: EdgeInsets.only(top: 30),
                alignment: Alignment.center,
                decoration: BoxDecoration(
                  border:
                      Border.all(width: 1, color: Colors.grey.withOpacity(0.9)),
                  borderRadius: BorderRadius.circular(75),
                  color: Colors.white,
                ),
                child: tx()

                // backgroundImage:  NetworkImage('https://pic2.zhimg.com/v2-639b49f2f6578eabddc458b84eb3c6a1.jpg'),
              ),
              onTap: (){
                print('$username');
                setState(() {
                  Navigator.of(context).push(MaterialPageRoute(
                      builder: (BuildContext context){
                        return personal();
                      }
                  )
                  );                //   跳转到个人页面
                });
              },
            ),

          ),

          //用户名显示
          Padding(
            padding: EdgeInsets.only(top: 10),
            child: Text('$username'),
          ),

          //我的发布、我的抢单
          Container(
            alignment: Alignment.center,
            color: Colors.white,
            child: Column(
              children: <Widget>[

                GestureDetector(
                  child: Container(
                  padding: EdgeInsets.only(top: 7),
                    alignment: Alignment.center,
                    width: 600,
                    color: Colors.white,
                    child: Row(
                      children: <Widget>[
                        SizedBox(width: 20,),
                        Icon(Icons.menu),
                        SizedBox(width: 10,),
                        Text('我的发布'),
                      ],)
                  ),
                  onTap: (){

                  },
                ),

                Divider(
                      indent: 20,
                      endIndent: 20,
                ),

                GestureDetector(
                  child: Container(
                    padding: EdgeInsets.only(bottom: 7),
                    alignment: Alignment.center,
                    width: 600,
                    color: Colors.white,
                    child: Row(
                      children: <Widget>[
                        SizedBox(width: 20,),
                      Icon(Icons.menu),
                      SizedBox(width: 10,),
                      Text('我的抢单'),
                    ],)
                  ),
                  onTap: (){
                  },
                ),
              ],
            ),
          ),
          //我的钱包、我的下级
          Container(
            margin: EdgeInsets.only(top: 20),
            alignment: Alignment.center,
            color: Colors.white,
            child: Column(
              children: <Widget>[
                GestureDetector(
                  child: Container(
                      padding: EdgeInsets.only(top: 7),
                      alignment: Alignment.center,
                      width: 600,
                      color: Colors.white,
                      child: Row(
                        children: <Widget>[
                          SizedBox(width: 20,),
                          Icon(Icons.menu),
                          SizedBox(width: 10,),
                          Text('我的钱包'),
                        ],)
                  ),
                  onTap: (){
                    print('我的钱包');
                  },
                ),

                Divider(
                  indent: 20,
                  endIndent: 20,
                ),

                GestureDetector(
                  child: Container(
                      padding: EdgeInsets.only(bottom: 7),
                      alignment: Alignment.center,
                      width: 600,
                      color: Colors.white,
                      child: Row(
                        children: <Widget>[
                          SizedBox(width: 20,),
                          Icon(Icons.menu),
                          SizedBox(width: 10,),
                          Text('我的下级'),
                        ],)
                  ),
                  onTap: (){
                  },
                ),
              ],
            ),
          ),

        //我的二维码、我的地址
          Container(
            margin: EdgeInsets.only(top: 20),
            alignment: Alignment.center,
            color: Colors.white,
            child: Column(
              children: <Widget>[
                GestureDetector(
                  child: Container(
                      padding: EdgeInsets.only(top: 7),
                      alignment: Alignment.center,
                      width: 600,
                      color: Colors.white,
                      child: Row(
                        children: <Widget>[
                          SizedBox(width: 20,),
                          Icon(Icons.menu),
                          SizedBox(width: 10,),
                          Text('我的二维码'),
                        ],)
                  ),
                  onTap: (){

                    Navigator.of(context).push(new MaterialPageRoute(
                        builder: (BuildContext context){
                          return MineQRCode();
                        }
                    )
                    );
                  }
                ),

                Divider(
                  indent: 20,
                  endIndent: 20,
                ),

                GestureDetector(
                  child: Container(
                      padding: EdgeInsets.only(bottom: 7),
                      alignment: Alignment.center,
                      width: 600,
                      color: Colors.white,
                      child: Row(
                        children: <Widget>[
                          SizedBox(width: 20,),
                          Icon(Icons.menu),
                          SizedBox(width: 10,),
                          Text('我的地址'),
                        ],
                      )
                  ),
                  onTap: (){

                  },
                ),
              ],
            ),
          ),

        ],

      ),
    )
    );
  }

  @override
  void initState() {
    // TODO: implement initState
    super.initState();

  }

  @override
  void dispose() {
    // TODO: implement dispose
    super.dispose();
  }

  tx() {
    if(todo.HaveTX == false){     //判断
      return Text('头像');
    }
      else{
      return ClipOval(
          child: Image.asset(todo.TxUrl, fit: BoxFit.fill, width: 100, height: 100,)
      );
    }
  }
}
